//第一种
function throttle(fun, delay) {
    let last, deferTime
    return function (args) {
        let now = +new Date()
        //设值last，是为了第一次一定要执行
        if (last && now < last + delay) {
            //最后按的一次也要执行
            clearTimeout(deferTime)
            deferTime = setTimeout(() => {
                last = now
                fun.call(this, ...args)
            }, delay)
        } else {
            last = now
            fun.call(this, ...args)
        }
    }
}